#include "RBM.h"

#include "../Utils/RandomUtil.h"

RBM::RBM(int vLayerDimension, int hLayerDimension) :
	m_matWeight(vLayerDimension, hLayerDimension),
	m_matVLBias(1, hLayerDimension),
	m_matHLBias(1, vLayerDimension)
{
	for (int line = 0; line < this->m_matWeight.GetLineCount(); line++)
	{
		for (int column = 0; column < this->m_matWeight.GetColumnCount(); column++)
		{
			this->m_matWeight[line][column] = RandomUtil::GenGaussianRandomNumber(0.0, 0.1);
		}
	}

	for (int n = 0; n < hLayerDimension; n++)
	{
		this->m_matVLBias[n][0] = 0.0;
	}

	for (int n = 0; n < vLayerDimension; n++)
	{
		this->m_matHLBias[n][0] = 0.0;
	}
}

const Matrix2 & RBM::GetWeightMatrix()
{
	return this->m_matWeight;
}

const Matrix2 & RBM::GetVisibleLayerBiasVector()
{
	return this->m_matVLBias;
}

const Matrix2 & RBM::GetHideLayerBiasVector()
{
	return this->m_matHLBias;
}

void RBM::ResetRBMParameter(const Matrix2 & weightMat, const Matrix2 & vLayerBiasVec, const Matrix2 & hLayerBiasVec)
{
	this->m_matWeight = weightMat;
	this->m_matVLBias = vLayerBiasVec;
	this->m_matHLBias = hLayerBiasVec;
}